<template>
  <div class="energy-system-container">
        <button class="distribution-btn emission-submit-btn" @click="submit">
          <span class="btn-text">提交</span>

        </button>
    <div class="storage-section">
      <h2 class="title">燃气锅炉</h2>
      <div class="info-grid">
        <div class="info-card">
          <label class="info-label">规定使用年限</label>
          <div class="info-content">
            <input type="number" v-model="ranqiguolu1" class="form-input small">
            <span class="info-value">年</span>
          </div>
        </div>

        <div class="info-card">
          <label class="info-label">投资成本</label>
          <div class="info-content">
            <input type="number" v-model="ranqiguolu2" class="form-input small">
            <span class="info-value">%</span>
          </div>
        </div>

        <div class="info-card">
          <label class="info-label">固定运维成本</label>
          <div class="info-content">
            <input type="number" v-model="ranqiguolu3" class="form-input small">
            <span class="info-value">%</span>
          </div>
        </div>


        <div class="info-card">
          <label class="info-label">可变运维成本</label>
          <div class="info-content">
            <input type="number" v-model="ranqiguolu4" class="form-input small">
            <span class="info-value">%</span>
          </div>
        </div>
      </div>
    </div>


    <div class="storage-section">
      <h2 class="title">凝汽式热电联产机组</h2>
      <div class="info-grid">
        <div class="info-card">
          <label class="info-label">规定使用年限</label>
          <div class="info-content">
            <input type="number" v-model="ningqishi1" class="form-input small">
            <span class="info-value">年</span>
          </div>
        </div>
        <div class="info-card">
          <label class="info-label">投资成本</label>
          <div class="info-content">
            <input type="number" v-model="ningqishi2" class="form-input small">
            <span class="info-value">元/kW</span>
          </div>
        </div>
        <div class="info-card">
          <label class="info-label">固定运维成本</label>
          <div class="info-content">
            <input type="number" v-model="ningqishi3" class="form-input small">
            <span class="info-value">元/kW</span>
          </div>
        </div>
        <div class="info-card">
          <label class="info-label">可变运维成本</label>
          <div class="info-content">
            <input type="number" v-model="ningqishi4" class="form-input small">
            <span class="info-value">元/kWh</span>
          </div>
        </div>
      </div>
    </div>

    <!-- 背压式热电联产机组 -->
    <div class="storage-section">
      <h2 class="title">背压式热电联产机组</h2>
      <div class="info-grid">
        <div class="info-card">
          <label class="info-label">规定使用年限</label>
          <div class="info-content">
            <input type="number" v-model="beiyashi1" class="form-input small">
            <span class="info-value">年</span>
          </div>
        </div>
        <div class="info-card">
          <label class="info-label">投资成本</label>
          <div class="info-content">
            <input type="number" v-model="beiyashi2" class="form-input small">
            <span class="info-value">元/kW</span>
          </div>
        </div>
        <div class="info-card">
          <label class="info-label">固定运维成本</label>
          <div class="info-content">
            <input type="number" v-model="beiyashi3" class="form-input small">
            <span class="info-value">元/kW</span>
          </div>
        </div>
        <div class="info-card">
          <label class="info-label">可变运维成本</label>
          <div class="info-content">
            <input type="number" v-model="beiyashi4" class="form-input small">
            <span class="info-value">元/kWh</span>
          </div>
        </div>
      </div>
    </div>


    <!-- 火力发电机组 -->
    <div class="storage-section">
      <h2 class="title">火力发电机组</h2>
      <div class="info-grid">
        <div class="info-card">
          <label class="info-label">规定使用年限</label>
          <div class="info-content">
            <input type="number" v-model="huoli1" class="form-input small">
            <span class="info-value">年</span>
          </div>
        </div>
        <div class="info-card">
          <label class="info-label">投资成本</label>
          <div class="info-content">
            <input type="number" v-model="huoli2" class="form-input small">
            <span class="info-value">元/kW</span>
          </div>
        </div>
        <div class="info-card">
          <label class="info-label">固定运维成本</label>
          <div class="info-content">
            <input type="number" v-model="huoli3" class="form-input small">
            <span class="info-value">元/kW</span>
          </div>
        </div>
        <div class="info-card">
          <label class="info-label">可变运维成本</label>
          <div class="info-content">
            <input type="number" v-model="huoli4" class="form-input small">
            <span class="info-value">元/kWh</span>
          </div>
        </div>
      </div>
    </div>

    <div class="storage-section">
      <h2 class="title">核电站</h2>
      <div class="info-grid">
        <div class="info-card">
          <label class="info-label">规定使用年限</label>
          <div class="info-content">
            <input type="number" v-model="hedian1" class="form-input small">
            <span class="info-value">年</span>
          </div>
        </div>
        <div class="info-card">
          <label class="info-label">投资成本</label>
          <div class="info-content">
            <input type="number" v-model="hedian2" class="form-input small">
            <span class="info-value">元/kW</span>
          </div>
        </div>
        <div class="info-card">
          <label class="info-label">固定运维成本</label>
          <div class="info-content">
            <input type="number" v-model="hedian3" class="form-input small">
            <span class="info-value">元/kW</span>
          </div>
        </div>
        <div class="info-card">
          <label class="info-label">可变运维成本</label>
          <div class="info-content">
            <input type="number" v-model="hedian4" class="form-input small">
            <span class="info-value">元/kWh</span>
          </div>
        </div>
      </div>
    </div>

    <div class="storage-section">
      <h2 class="title">地热能机组</h2>
      <div class="info-grid">
        <div class="info-card">
          <label class="info-label">规定使用年限</label>
          <div class="info-content">
            <input type="number" v-model="dire1" class="form-input small">
            <span class="info-value">年</span>
          </div>
        </div>
        <div class="info-card">
          <label class="info-label">投资成本</label>
          <div class="info-content">
            <input type="number" v-model="dire2" class="form-input small">
            <span class="info-value">元/kW</span>
          </div>
        </div>
        <div class="info-card">
          <label class="info-label">固定运维成本</label>
          <div class="info-content">
            <input type="number" v-model="dire3" class="form-input small">
            <span class="info-value">元/kW</span>
          </div>
        </div>
        <div class="info-card">
          <label class="info-label">可变运维成本</label>
          <div class="info-content">
            <input type="number" v-model="dire4" class="form-input small">
            <span class="info-value">元/kWh</span>
          </div>
        </div>
      </div>
    </div>

    <div class="storage-section">
      <h2 class="title">抽水蓄能</h2>
      <div class="info-grid">
        <div class="info-card">
          <label class="info-label">规定使用年限</label>
          <div class="info-content">
            <input type="number" v-model="choushui1" class="form-input small">
            <span class="info-value">年</span>
          </div>
        </div>
        <div class="info-card">
          <label class="info-label">投资成本</label>
          <div class="info-content">
            <input type="number" v-model="choushui2" class="form-input small">
            <span class="info-value">元/kW</span>
          </div>
        </div>
        <div class="info-card">
          <label class="info-label">固定运维成本</label>
          <div class="info-content">
            <input type="number" v-model="choushui3" class="form-input small">
            <span class="info-value">元/kW</span>
          </div>
        </div>
        <div class="info-card">
          <label class="info-label">可变运维成本</label>
          <div class="info-content">
            <input type="number" v-model="choushui4" class="form-input small">
            <span class="info-value">元/kWh</span>
          </div>
        </div>
      </div>
    </div>

    <div class="storage-section">
      <h2 class="title">分布式光伏</h2>
      <div class="info-grid">
        <div class="info-card">
          <label class="info-label">规定使用年限</label>
          <div class="info-content">
            <input type="number" v-model="fenbushi1" class="form-input small">
            <span class="info-value">年</span>
          </div>
        </div>
        <div class="info-card">
          <label class="info-label">投资成本</label>
          <div class="info-content">
            <input type="number" v-model="fenbushi2" class="form-input small">
            <span class="info-value">元/kW</span>
          </div>
        </div>
        <div class="info-card">
          <label class="info-label">固定运维成本</label>
          <div class="info-content">
            <input type="number" v-model="fenbushi3" class="form-input small">
            <span class="info-value">元/kW</span>
          </div>
        </div>
        <div class="info-card">
          <label class="info-label">可变运维成本</label>
          <div class="info-content">
            <input type="number" v-model="fenbushi4" class="form-input small">
            <span class="info-value">元/kWh</span>
          </div>
        </div>
      </div>
    </div>

    <div class="storage-section">
      <h2 class="title">集中式光伏</h2>
      <div class="info-grid">
        <div class="info-card">
          <label class="info-label">规定使用年限</label>
          <div class="info-content">
            <input type="number" v-model="jizhongshi1" class="form-input small">
            <span class="info-value">年</span>
          </div>
        </div>
        <div class="info-card">
          <label class="info-label">投资成本</label>
          <div class="info-content">
            <input type="number" v-model="jizhongshi2" class="form-input small">
            <span class="info-value">元</span>
          </div>
        </div>
        <div class="info-card">
          <label class="info-label">固定运维成本</label>
          <div class="info-content">
            <input type="number" v-model="jizhongshi3" class="form-input small">
            <span class="info-value">元</span>
          </div>
        </div>
        <div class="info-card">
          <label class="info-label">可变运维成本</label>
          <div class="info-content">
            <input type="number" v-model="jizhongshi4" class="form-input small">
            <span class="info-value">元</span>
          </div>
        </div>
      </div>
    </div>

    <div class="storage-section">
      <h2 class="title">海上风电</h2>
      <div class="info-grid">
        <div class="info-card">
          <label class="info-label">规定使用年限</label>
          <div class="info-content">
            <input type="number" v-model="haishang1" class="form-input small">
            <span class="info-value">年</span>
          </div>
        </div>
        <div class="info-card">
          <label class="info-label">投资成本</label>
          <div class="info-content">
            <input type="number" v-model="haishang2" class="form-input small">
            <span class="info-value">元</span>
          </div>
        </div>
        <div class="info-card">
          <label class="info-label">固定运维成本</label>
          <div class="info-content">
            <input type="number" v-model="haishang3" class="form-input small">
            <span class="info-value">元</span>
          </div>
        </div>
        <div class="info-card">
          <label class="info-label">可变运维成本</label>
          <div class="info-content">
            <input type="number" v-model="haishang4" class="form-input small">
            <span class="info-value">元</span>
          </div>
        </div>
      </div>
    </div>

    <div class="storage-section">
      <h2 class="title">陆上风电</h2>
      <div class="info-grid">
        <div class="info-card">
          <label class="info-label">规定使用年限</label>
          <div class="info-content">
            <input type="number" v-model="lushang1" class="form-input small">
            <span class="info-value">年</span>
          </div>
        </div>
        <div class="info-card">
          <label class="info-label">投资成本</label>
          <div class="info-content">
            <input type="number" v-model="lushang2" class="form-input small">
            <span class="info-value">元</span>
          </div>
        </div>
        <div class="info-card">
          <label class="info-label">固定运维成本</label>
          <div class="info-content">
            <input type="number" v-model="lushang3" class="form-input small">
            <span class="info-value">元</span>
          </div>
        </div>
        <div class="info-card">
          <label class="info-label">可变运维成本</label>
          <div class="info-content">
            <input type="number" v-model="lushang4" class="form-input small">
            <span class="info-value">元/</span>
          </div>
        </div>
      </div>
    </div>

    <div class="storage-section">
      <h2 class="title">聚光太阳能</h2>
      <div class="info-grid">
        <div class="info-card">
          <label class="info-label">规定使用年限</label>
          <div class="info-content">
            <input type="number" v-model="juguang1" class="form-input small">
            <span class="info-value">年</span>
          </div>
        </div>
        <div class="info-card">
          <label class="info-label">投资成本</label>
          <div class="info-content">
            <input type="number" v-model="juguang2" class="form-input small">
            <span class="info-value">元</span>
          </div>
        </div>
        <div class="info-card">
          <label class="info-label">固定运维成本</label>
          <div class="info-content">
            <input type="number" v-model="juguang3" class="form-input small">
            <span class="info-value">元</span>
          </div>
        </div>
        <div class="info-card">
          <label class="info-label">可变运维成本</label>
          <div class="info-content">
            <input type="number" v-model="juguang4" class="form-input small">
            <span class="info-value">元</span>
          </div>
        </div>
      </div>
    </div>

    <div class="storage-section">
      <h2 class="title">太阳能供热</h2>
      <div class="info-grid">
        <div class="info-card">
          <label class="info-label">规定使用年限</label>
          <div class="info-content">
            <input type="number" v-model="gongre1" class="form-input small">
            <span class="info-value">年</span>
          </div>
        </div>
        <div class="info-card">
          <label class="info-label">投资成本</label>
          <div class="info-content">
            <input type="number" v-model="gongre2" class="form-input small">
            <span class="info-value">元/kW</span>
          </div>
        </div>
        <div class="info-card">
          <label class="info-label">固定运维成本</label>
          <div class="info-content">
            <input type="number" v-model="gongre3" class="form-input small">
            <span class="info-value">元/kW</span>
          </div>
        </div>
        <div class="info-card">
          <label class="info-label">可变运维成本</label>
          <div class="info-content">
            <input type="number" v-model="gongre4" class="form-input small">
            <span class="info-value">元/kWh</span>
          </div>
        </div>
      </div>
    </div>

    <div class="storage-section">
      <h2 class="title">压缩式热泵</h2>
      <div class="info-grid">
        <div class="info-card">
          <label class="info-label">规定使用年限</label>
          <div class="info-content">
            <input type="number" v-model="yasuo1" class="form-input small">
            <span class="info-value">年</span>
          </div>
        </div>
        <div class="info-card">
          <label class="info-label">投资成本</label>
          <div class="info-content">
            <input type="number" v-model="yasuo2" class="form-input small">
            <span class="info-value">元</span>
          </div>
        </div>
        <div class="info-card">
          <label class="info-label">固定运维成本</label>
          <div class="info-content">
            <input type="number" v-model="yasuo3" class="form-input small">
            <span class="info-value">元</span>
          </div>
        </div>
        <div class="info-card">
          <label class="info-label">可变运维成本</label>
          <div class="info-content">
            <input type="number" v-model="yasuo4" class="form-input small">
            <span class="info-value">元</span>
          </div>
        </div>
      </div>
    </div>

    <div class="storage-section">
      <h2 class="title">地源热泵</h2>
      <div class="info-grid">
        <div class="info-card">
          <label class="info-label">规定使用年限</label>
          <div class="info-content">
            <input type="number" v-model="diyuan1" class="form-input small">
            <span class="info-value">年</span>
          </div>
        </div>
        <div class="info-card">
          <label class="info-label">投资成本</label>
          <div class="info-content">
            <input type="number" v-model="diyuan2" class="form-input small">
            <span class="info-value">元</span>
          </div>
        </div>
        <div class="info-card">
          <label class="info-label">固定运维成本</label>
          <div class="info-content">
            <input type="number" v-model="diyuan3" class="form-input small">
            <span class="info-value">元</span>
          </div>
        </div>
        <div class="info-card">
          <label class="info-label">可变运维成本</label>
          <div class="info-content">
            <input type="number" v-model="diyuan4" class="form-input small">
            <span class="info-value">元</span>
          </div>
        </div>
      </div>
    </div>

</div>
</template>

<script lang="ts" setup>
import { ref, onMounted, type Ref } from 'vue'
import axios from 'axios'
import { ElMessage } from 'element-plus'

const submit = async () => {
  try {
    const payloads = [
      { id: 7, value: parseFloat(ranqiguolu1.value) || 0, url: 'guolu' },
      { id: 8, value: parseFloat(ranqiguolu2.value) || 0, url: 'guolu' },
      { id: 9, value: parseFloat(ranqiguolu3.value) || 0, url: 'guolu' },
      { id: 10, value: parseFloat(ranqiguolu4.value) || 0, url: 'guolu' },
      { id: 5, value: parseFloat(ningqishi1.value) || 0 , url: 'ningqi'},
      { id: 6, value: parseFloat(ningqishi2.value) || 0 , url: 'ningqi'},
      { id: 7, value: parseFloat(ningqishi3.value) || 0 , url: 'ningqi'},
      { id: 8, value: parseFloat(ningqishi4.value) || 0 , url: 'ningqi'},
      { id: 9, value: parseFloat(beiyashi1.value) || 0 , url: 'beiya'},
      { id: 10, value: parseFloat(beiyashi2.value) || 0, url: 'beiya' },
      { id: 11, value: parseFloat(beiyashi3.value) || 0 , url: 'beiya'},
      { id: 12, value: parseFloat(beiyashi4.value) || 0 , url: 'beiya'},
      { id: 13, value: parseFloat(huoli1.value) || 0, url: 'huoli' },
      { id: 14, value: parseFloat(huoli2.value) || 0 , url: 'huoli'},
      { id: 15, value: parseFloat(huoli3.value) || 0 , url: 'huoli'},
      { id: 16, value: parseFloat(huoli4.value) || 0 , url: 'huoli'},
      { id: 17, value: parseFloat(hedian1.value) || 0 , url: 'hedian'},
      { id: 18, value: parseFloat(hedian2.value) || 0 , url: 'hedian'},
      { id: 19, value: parseFloat(hedian3.value) || 0 , url: 'hedian'},
      { id: 4, value: parseFloat(hedian4.value) || 0 , url: 'hedian'},
      { id: 1, value: parseFloat(dire1.value) || 0 , url: 'dire'},
      { id: 2, value: parseFloat(dire2.value) || 0 , url: 'dire'},
      { id: 3, value: parseFloat(dire3.value) || 0 , url: 'dire'},
      { id: 4, value: parseFloat(dire4.value) || 0 , url: 'dire'},
      { id: 1, value: parseFloat(choushui1.value) || 0, url: 'choushui' },
      { id: 2, value: parseFloat(choushui2.value) || 0, url: 'choushui' },
      { id: 3, value: parseFloat(choushui3.value) || 0 , url: 'choushui'},
      { id: 4, value: parseFloat(choushui4.value) || 0, url: 'choushui' },
      { id: 1, value: parseFloat(fenbushi1.value) || 0, url: 'fenbushi' },
      { id: 2, value: parseFloat(fenbushi2.value) || 0, url: 'fenbushi' },
      { id: 3, value: parseFloat(fenbushi3.value) || 0, url: 'fenbushi' },
      { id: 4, value: parseFloat(fenbushi4.value) || 0, url: 'fenbushi' },
      { id: 1, value: parseFloat(jizhongshi1.value) || 0, url: 'jizhong'  },
      { id: 2, value: parseFloat(jizhongshi2.value) || 0, url: 'jizhong'  },
      { id: 3, value: parseFloat(jizhongshi3.value) || 0, url: 'jizhong'  },
      { id: 4, value: parseFloat(jizhongshi4.value) || 0, url: 'jizhong'  },
      { id: 1, value: parseFloat(haishang1.value) || 0, url: 'haishang' },
      { id: 2, value: parseFloat(haishang2.value) || 0, url: 'haishang' },
      { id: 3, value: parseFloat(haishang3.value) || 0, url: 'haishang' },
      { id: 4, value: parseFloat(haishang4.value) || 0, url: 'haishang' },
      { id: 1, value: parseFloat(lushang1.value) || 0 , url: 'lushang'},
      { id: 2, value: parseFloat(lushang2.value) || 0, url: 'lushang' },
      { id: 3, value: parseFloat(lushang3.value) || 0, url: 'lushang' },
      { id: 4, value: parseFloat(lushang4.value) || 0, url: 'lushang' },
      { id: 1, value: parseFloat(juguang1.value) || 0, url: 'juguang' },
      { id: 2, value: parseFloat(juguang2.value) || 0, url: 'juguang' },
      { id: 3, value: parseFloat(juguang3.value) || 0, url: 'juguang' },
      { id: 4, value: parseFloat(juguang4.value) || 0, url: 'juguang' },
      { id: 1, value: parseFloat(gongre1.value) || 0, url: 'gongre'  },
      { id: 2, value: parseFloat(gongre2.value) || 0, url: 'gongre'  },
      { id: 3, value: parseFloat(gongre3.value) || 0 , url: 'gongre' },
      { id: 4, value: parseFloat(gongre4.value) || 0 , url: 'gongre' },
      { id: 1, value: parseFloat(yasuo1.value) || 0, url: 'yasuo' },
      { id: 2, value: parseFloat(yasuo2.value) || 0, url: 'yasuo' },
      { id: 3, value: parseFloat(yasuo3.value) || 0, url: 'yasuo' },
      { id: 4, value: parseFloat(yasuo4.value) || 0, url: 'yasuo' },
      { id: 1, value: parseFloat(diyuan1.value) || 0, url: 'diyuan'  },
      { id: 2, value: parseFloat(diyuan2.value) || 0, url: 'diyuan'  },
      { id: 3, value: parseFloat(diyuan3.value) || 0, url: 'diyuan'  },
      { id: 4, value: parseFloat(diyuan4.value) || 0, url: 'diyuan'  },

    ];

    for (const item of payloads) {
       await axios.put(`http://localhost:8080/${item.url}`, item);
    }

    ElMessage.success('已成功更新到数据库');
  } catch (error) {
    console.error('提交失败:', error);
    ElMessage.error('提交失败，请检查数据格式或网络连接');
  }
};

const fetchAndSet = async (url: string, variable: Ref<string>) => {
  try {
    const response = await axios.get(url);
    variable.value = response.data.value;
  } catch  {
    ElMessage.error(`加载 ${url} 失败`);
  }
};

onMounted(async () => {

    await fetchAndSet('http://localhost:8080/guolu/7', ranqiguolu1);
    await fetchAndSet('http://localhost:8080/guolu/8', ranqiguolu2);
    await fetchAndSet('http://localhost:8080/guolu/9', ranqiguolu3);
    await fetchAndSet('http://localhost:8080/guolu/10', ranqiguolu4);

    await fetchAndSet('http://localhost:8080/ningqi/7', ningqishi1);
    await fetchAndSet('http://localhost:8080/ningqi/8', ningqishi2);
    await fetchAndSet('http://localhost:8080/ningqi/9', ningqishi3);
    await fetchAndSet('http://localhost:8080/ningqi/10', ningqishi4);

    await fetchAndSet('http://localhost:8080/beiya/13', beiyashi1);
    await fetchAndSet('http://localhost:8080/beiya/14', beiyashi2);
    await fetchAndSet('http://localhost:8080/beiya/15', beiyashi3);
    await fetchAndSet('http://localhost:8080/beiya/16', beiyashi4);

    await fetchAndSet('http://localhost:8080/huoli/1', huoli1);
    await fetchAndSet('http://localhost:8080/huoli/2', huoli2);
    await fetchAndSet('http://localhost:8080/huoli/3', huoli3);
    await fetchAndSet('http://localhost:8080/huoli/4', huoli4);


    await fetchAndSet('http://localhost:8080/hedian/1', hedian1);
    await fetchAndSet('http://localhost:8080/hedian/2', hedian2);
    await fetchAndSet('http://localhost:8080/hedian/3', hedian3);
    await fetchAndSet('http://localhost:8080/hedian/4', hedian4);

    await fetchAndSet('http://localhost:8080/dire/1', dire1);
    await fetchAndSet('http://localhost:8080/dire/2', dire2);
    await fetchAndSet('http://localhost:8080/dire/3', dire3);
    await fetchAndSet('http://localhost:8080/dire/4', dire4);

    await fetchAndSet('http://localhost:8080/choushui/1', choushui1);
    await fetchAndSet('http://localhost:8080/choushui/2', choushui2);
    await fetchAndSet('http://localhost:8080/choushui/3', choushui3);
    await fetchAndSet('http://localhost:8080/choushui/4', choushui4);


    await fetchAndSet('http://localhost:8080/fenbushi/1', fenbushi1);
    await fetchAndSet('http://localhost:8080/fenbushi/2', fenbushi2);
    await fetchAndSet('http://localhost:8080/fenbushi/3', fenbushi3);
    await fetchAndSet('http://localhost:8080/fenbushi/4', fenbushi4);

    await fetchAndSet('http://localhost:8080/jizhong/1', jizhongshi1);
    await fetchAndSet('http://localhost:8080/jizhong/2', jizhongshi2);
    await fetchAndSet('http://localhost:8080/jizhong/3', jizhongshi3);
    await fetchAndSet('http://localhost:8080/jizhong/4', jizhongshi4);

    await fetchAndSet('http://localhost:8080/haishang/1', haishang1);
    await fetchAndSet('http://localhost:8080/haishang/2', haishang2);
    await fetchAndSet('http://localhost:8080/haishang/3', haishang3);
    await fetchAndSet('http://localhost:8080/haishang/4', haishang4);

    await fetchAndSet('http://localhost:8080/lushang/1', lushang1);
    await fetchAndSet('http://localhost:8080/lushang/2', lushang2);
    await fetchAndSet('http://localhost:8080/lushang/3', lushang3);
    await fetchAndSet('http://localhost:8080/lushang/4', lushang4);

    await fetchAndSet('http://localhost:8080/juguang/1', juguang1);
    await fetchAndSet('http://localhost:8080/juguang/2', juguang2);
    await fetchAndSet('http://localhost:8080/juguang/3', juguang3);
    await fetchAndSet('http://localhost:8080/juguang/4', juguang4);

    await fetchAndSet('http://localhost:8080/gongre/1', gongre1);
    await fetchAndSet('http://localhost:8080/gongre/2', gongre2);
    await fetchAndSet('http://localhost:8080/gongre/3', gongre3);
    await fetchAndSet('http://localhost:8080/gongre/4', gongre4);

    await fetchAndSet('http://localhost:8080/yasuo/1', yasuo1);
    await fetchAndSet('http://localhost:8080/yasuo/2', yasuo2);
    await fetchAndSet('http://localhost:8080/yasuo/3', yasuo3);
    await fetchAndSet('http://localhost:8080/yasuo/4', yasuo4);

    await fetchAndSet('http://localhost:8080/diyuan/1', diyuan1);
    await fetchAndSet('http://localhost:8080/diyuan/2', diyuan2);
    await fetchAndSet('http://localhost:8080/diyuan/3', diyuan3);
    await fetchAndSet('http://localhost:8080/diyuan/4', diyuan4);
  }
)
    const ranqiguolu1 = ref('')
    const ranqiguolu2 = ref('')
    const ranqiguolu3 = ref('')
    const ranqiguolu4 = ref('')

    const ningqishi1 = ref('')
    const ningqishi2 = ref('')
    const ningqishi3 = ref('')
    const ningqishi4 = ref('')

    const beiyashi1 = ref('')
    const beiyashi2 = ref('')
    const beiyashi3 = ref('')
    const beiyashi4 = ref('')

    const huoli1 = ref('')
    const huoli2 = ref('')
    const huoli3 = ref('')
    const huoli4 = ref('')

    const hedian1 = ref('')
    const hedian2 = ref('')
    const hedian3 = ref('')
    const hedian4 = ref('')

    const dire1 = ref('')
    const dire2 = ref('')
    const dire3 = ref('')
    const dire4 = ref('')

    const choushui1 = ref('')
    const choushui2 = ref('')
    const choushui3 = ref('')
    const choushui4 = ref('')

    const fenbushi1 = ref('')
    const fenbushi2 = ref('')
    const fenbushi3 = ref('')
    const fenbushi4 = ref('')

    const jizhongshi1 = ref('')
    const jizhongshi2 = ref('')
    const jizhongshi3 = ref('')
    const jizhongshi4 = ref('')

    const haishang1 = ref('')
    const haishang2 = ref('')
    const haishang3 = ref('')
    const haishang4 = ref('')

    const lushang1 = ref('')
    const lushang2 = ref('')
    const lushang3 = ref('')
    const lushang4 = ref('')

    const juguang1 = ref('')
    const juguang2 = ref('')
    const juguang3 = ref('')
    const juguang4 = ref('')

    const gongre1 = ref('')
    const gongre2 = ref('')
    const gongre3 = ref('')
    const gongre4 = ref('')

    const yasuo1 = ref('')
    const yasuo2 = ref('')
    const yasuo3 = ref('')
    const yasuo4 = ref('')

    const diyuan1 = ref('')
    const diyuan2 = ref('')
    const diyuan3 = ref('')
    const diyuan4 = ref('')

</script>

<style scoped>
.submit-emission-container {
  text-align: center;
  margin-top: 24px;
}

.emission-submit-btn {
  background-color: #7c3aed; /* 绿色 */
  padding: 12px 24px;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 600;
  box-shadow: 0 4px 10px rgba(22, 163, 74, 0.2);
}

.emission-submit-btn:hover {
  background-color: #7c3aed;
  box-shadow: 0 6px 16px rgba(22, 163, 74, 0.3);
}
.electricity-container {
  background-color: #f8fafc;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
  border-radius: 14px;
  padding: 36px;
  max-width: 920px;
  margin: 0 auto;
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  color: #1e293b;
}

.title {
  color: #4c1d95;
  text-align: center;
  margin-bottom: 32px;
  font-size: 28px;
  font-weight: 700;
  padding-bottom: 16px;
  border-bottom: 2px solid #7c3aed;
  letter-spacing: 0.5px;
}

.storage-section {
  background-color: white;
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 28px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 18px;
}

.info-card {
  background-color: #f8fafc;
  padding: 18px;
  border-radius: 10px;
  border-left: 4px solid #7c3aed;
  transition: transform 0.2s, box-shadow 0.2s;
}

.info-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.info-label {
  display: block;
  font-weight: 500;
  color: #475569;
  margin-bottom: 10px;
  font-size: 15px;
}

.info-content {
  display: flex;
  align-items: center;
  gap: 12px;
}

.form-input {
  padding: 10px 16px;
  border: 1px solid #053676;
  border-radius: 6px;
  width: 120px;
  text-align: right;
  font-size: 15px;
  background: transparent;
  color: #1e293b;
  border: 1px solid #053676;
}

.form-input.small {
  width: 100px;
}

.form-input:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.2);
}

.info-value {
  font-weight: 600;
  color: #4c1d95;
  font-size: 15px;
  white-space: nowrap;
}

.save-btn {
  background-color: #7c3aed;
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s;
  margin-top: 20px;
}

.save-btn:hover {
  background-color: #6d28d9;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(124, 58, 237, 0.3);
}

@media (max-width: 768px) {
  .electricity-container {
    padding: 24px;
    border-radius: 0;
  }

  .info-grid {
    grid-template-columns: 1fr;
  }

  .form-input {
    width: 100%;
  }
}
</style>
